<template>
<table>
    <tr>
        <td>投资项目名称</td>
        <td><input type="text" v-model="info.Iname"></td>
    </tr>
    <tr>
        <td>投资总金额</td>
        <td><input type="text" v-model="info.Isumprice"></td>
    </tr>
    <tr>
        <td colspan="2"><button @click="AddInfo">保存</button></td>
    </tr>
</table>
</template>
<script setup lang="ts">
import axios from 'axios';
import {ref}from'vue'
const info=ref({
    Iname:'',
    Isumprice:''
})
const AddInfo=()=>{
    if(info.value.Iname==''||info.value.Isumprice==''){
        alert("输入不能为空")
        return
    }
    if(Number(info.value.Isumprice)<0||Number(info.value.Isumprice)>10000000){
        alert("投资总金额需大于0元且小于1千万")
        return
    }

    axios.post('https://localhost:44324/api/Lx/AddInfo',{
        Iname:info.value.Iname,
        Isumprice:info.value.Isumprice
    }).then(res=>{
        if(res.data>0){
            alert("添加成功")
        }else{
            alert("添加失败")
        }
    }).catch(err=>{
        console.log(err)    
    })
}

</script>